package com.songlanyun.modules.singlegoods.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Date;

import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.songlanyun.common.drive.RootEntity;
import com.songlanyun.common.enums.GoodsConstant;
import lombok.Data;

import javax.swing.*;

/**
 * 单品的库存变动记录表
 *
 * @author lubo
 * @email sunlightcs@gmail.com
 * @date 2020-11-04 09:03:01
 */
@Data
@TableName("yxt_product_single_goods_stock_record")
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
public class ProductSingleGoodsStockRecordEntity extends RootEntity<Long, ProductSingleGoodsEntity> implements Serializable {
    private static final long serialVersionUID = 1L;

    {
        singleGoodsTitle = "";
        singleGoodsCode = "";
        stockStartNum = 0;
        stockEndNum = 0;
        stockChangeNum = 0;
        inStockType = GoodsConstant.InStockType.EMPTY;
        outStockType = GoodsConstant.OuterStockType.EMPTY;
        stockChangeMode = GoodsConstant.StockChangeMode.IN;
        coverImage = "";
        sku = "";
        unit = "";
        orderId = 0L;
        orderCode = "";
        childReferId = 0L;
        rightsChildId = 0L;
        rightsId = 0L;
        rightsCode = "";
        remark = "";

    }

    /**
     *
     */
    @TableId
    private Long id;
    /**
     * 商家店铺id
     */
    private Long shopId;
    /**
     * 单品id
     */
    private Long singleGoodsId;
    /**
     * 单品标题
     */
    private String singleGoodsTitle;
    /**
     * 单品编码
     */
    private String singleGoodsCode;
    /**
     * 操作前的数量
     */
    private Integer stockStartNum;
    /**
     * 操作后的数量
     */
    private Integer stockEndNum;
    /**
     * 改变的数量
     */
    private Integer stockChangeNum;

    /**
     * 入库类型(0无，1初始化库存，2手动入库，3维权入库，4撤单入库，5，支付过期入库，6自提过期，7支付成功,条件不允许,自动退款关闭
     */
    private GoodsConstant.InStockType inStockType;
    /**
     * 0空，1下单出库，2手单出库
     */
    private GoodsConstant.OuterStockType outStockType;

    @TableField(exist = false)
    private String stockTypeStr;

    public String getStockTypeStr() {
        if (GoodsConstant.StockChangeMode.IN == stockChangeMode) {
            //入库
            return this.inStockType.getMsg();
        } else {
            return this.outStockType.getMsg();
        }
    }


    /**
     * 出入库的模式（0入，1出）
     */
    private GoodsConstant.StockChangeMode stockChangeMode;
    /**
     * 单品封面图片
     */
    private String coverImage;
    /**
     * 单品的sku描述
     */
    private String sku;
    /**
     * 单位
     */
    private String unit;
    /**
     * 订单id
     */
    private Long orderId;

    /**
     * 订单编号
     */
    private String orderCode;
    /**
     * 子订单编号
     */
    private Long childReferId;

    /**
     * 细节描述
     */
    private String remark;
    /**
     * 维权单id
     */
    private Long rightsId;
    /**
     * 维权单编号
     */
    private String rightsCode;

    /**
     * 维权子单id
     */
    private Long rightsChildId;
    /**
     *
     */
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    @Override
    public Long getIdentity() {
        return getId();
    }
}
